package chapter15;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/3/14 14:01
 */
class Building{}

class House extends Building{}

public class ClassTypeCapture<T> {
    Class<T> kind;

    public ClassTypeCapture(Class<T> kind) {
        this.kind = kind;
    }

    public boolean f(Object object) {
        return kind.isInstance(object);
    }

    public static void main(String[] args) {
        ClassTypeCapture<Building> ctl1 = new ClassTypeCapture<>(Building.class);
        System.out.println(ctl1.f(new Building()));
        System.out.println(ctl1.f(new House()));

        ClassTypeCapture<House> ctl2 = new ClassTypeCapture<>(House.class);
        System.out.println(ctl2.f(new Building()));
        System.out.println(ctl2.f(new House()));
    }
}
